home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / CTYPE.H < prev    next >
C/C++ Source or Header  |  1993-11-23  |  4KB  |  128 lines

  1. /***
  2. *ctype.h - character conversion macros and ctype macros
  3. *
  4. *   Copyright (c) 1985-1992, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *   Defines macros for character classification/conversion.
  8. *   [ANSI/System V]
  9. *
  10. ****/
  11.  
  12. #ifndef _INC_CTYPE
  13.  
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif 
  17.  
  18. #if (_MSC_VER <= 600)
  19. #define __cdecl     _cdecl
  20. #define __far       _far
  21. #define __near      _near
  22. #endif 
  23.  
  24. /*
  25.  * This declaration allows the user access to the ctype look-up
  26.  * array _ctype defined in ctype.obj by simply including ctype.h
  27.  */
  28.  
  29. extern unsigned char __near __cdecl _ctype[];
  30.  
  31. /* set bit masks for the possible character types */
  32.  
  33. #define _UPPER      0x1 /* upper case letter */
  34. #define _LOWER      0x2 /* lower case letter */
  35. #define _DIGIT      0x4 /* digit[0-9] */
  36. #define _SPACE      0x8 /* tab, carriage return, newline, */
  37.                 /* vertical tab or form feed */
  38. #define _PUNCT      0x10    /* punctuation character */
  39. #define _CONTROL    0x20    /* control character */
  40. #define _BLANK      0x40    /* space char */
  41. #define _HEX        0x80    /* hexadecimal digit */
  42.  
  43. /* character classification function prototypes */
  44.  
  45. #ifndef _CTYPE_DEFINED
  46. int __cdecl isalpha(int);
  47. int __cdecl isupper(int);
  48. int __cdecl islower(int);
  49. int __cdecl isdigit(int);
  50. int __cdecl isxdigit(int);
  51. int __cdecl isspace(int);
  52. int __cdecl ispunct(int);
  53. int __cdecl isalnum(int);
  54. int __cdecl isprint(int);
  55. int __cdecl isgraph(int);
  56. int __cdecl iscntrl(int);
  57. int __cdecl toupper(int);
  58. int __cdecl tolower(int);
  59. int __cdecl _tolower(int);
  60. int __cdecl _toupper(int);
  61. int __cdecl __isascii(int);
  62. int __cdecl __toascii(int);
  63. int __cdecl __iscsymf(int);
  64. int __cdecl __iscsym(int);
  65. #define _CTYPE_DEFINED
  66. #endif 
  67.  
  68. #ifdef _INTL
  69. int __cdecl __isleadbyte(int);
  70. #endif 
  71.  
  72. /* the character classification macro definitions */
  73.  
  74. #define isalpha(_c) ( (_ctype+1)[_c] & (_UPPER|_LOWER) )
  75. #define isupper(_c) ( (_ctype+1)[_c] & _UPPER )
  76. #define islower(_c) ( (_ctype+1)[_c] & _LOWER )
  77. #define isdigit(_c) ( (_ctype+1)[_c] & _DIGIT )
  78. #define isxdigit(_c)    ( (_ctype+1)[_c] & _HEX )
  79. #define isspace(_c) ( (_ctype+1)[_c] & _SPACE )
  80. #define ispunct(_c) ( (_ctype+1)[_c] & _PUNCT )
  81. #define isalnum(_c) ( (_ctype+1)[_c] & (_UPPER|_LOWER|_DIGIT) )
  82. #define isprint(_c) ( (_ctype+1)[_c] & (_BLANK|_PUNCT|_UPPER|_LOWER|_DIGIT) )
  83. #define isgraph(_c) ( (_ctype+1)[_c] & (_PUNCT|_UPPER|_LOWER|_DIGIT) )
  84. #define iscntrl(_c) ( (_ctype+1)[_c] & _CONTROL )
  85. #ifndef __STDC__
  86. #define toupper(_c) ( (islower(_c)) ? _toupper(_c) : (_c) )
  87. #define tolower(_c) ( (isupper(_c)) ? _tolower(_c) : (_c) )
  88. #endif 
  89. #define _tolower(_c)    ( (_c)-'A'+'a' )
  90. #define _toupper(_c)    ( (_c)-'a'+'A' )
  91. #define __isascii(_c)   ( (unsigned)(_c) < 0x80 )
  92. #define __toascii(_c)   ( (_c) & 0x7f )
  93.  
  94. #ifndef isleadbyte
  95. #ifdef _INTL
  96. #define isleadbyte(_c)  __isleadbyte(_c)
  97. #else 
  98. #define isleadbyte(_c)  (0)
  99. #endif 
  100. #endif 
  101.  
  102. /* extended ctype macros */
  103.  
  104. #define __iscsymf(_c)   (isalpha(_c) || ((_c) == '_'))
  105. #define __iscsym(_c)    (isalnum(_c) || ((_c) == '_'))
  106.  
  107. #ifndef __STDC__
  108. /* Non-ANSI names for compatibility */
  109. #ifndef _CTYPE_DEFINED
  110. int __cdecl isascii(int);
  111. int __cdecl toascii(int);
  112. int __cdecl iscsymf(int);
  113. int __cdecl iscsym(int);
  114. #else 
  115. #define isascii __isascii
  116. #define toascii __toascii
  117. #define iscsymf __iscsymf
  118. #define iscsym  __iscsym
  119. #endif 
  120. #endif 
  121.  
  122. #ifdef __cplusplus
  123. }
  124. #endif 
  125.  
  126. #define _INC_CTYPE
  127. #endif 
  128.